--
-- Add recipe to upgrade some items from pipeworks
--

local pipeworks_mods = {"pipeworks", "liteworks"}

for i = 1, #pipeworks_mods  do
  local pipeworks_mod = pipeworks_mods[i]
  if minetest.get_modpath("default") and minetest.get_modpath(pipeworks_mod) then

    -- Upgrade filter injector (less expensive than crafting a new one)
    local s = "default:mese_crystal"
    local f = pipeworks_mod..":filter"
    minetest.register_craft( {
      output = pipeworks_mod..":mese_filter 2",
      recipe = {
          { s, s, s },
          { s, f, s },
          { s, s, s }
      },
    })

      -- -------------------------------------------------------------- --
      
      -- Autocrafter is like an upgraded craft_bench
      if minetest.registered_items["crafting_bench:workbench"] then
          local b = "crafting_bench:workbench"
          local c = ""
          local m = "default:mese_crystal_fragment"
          if minetest.get_modpath("mesecons") then m = "mesecons:mesecon" end
          
          minetest.register_craft( {
              output = pipeworks_mod..":autocrafter",
              -- type = shapeless,
              -- recipe = { "default:mese_crystal", "default:mese" }
              recipe = {
                      { c, m, c },
                      { m, b, m },
                      { c, m, c }
              },
          })
      end

  end
end
